<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CrateAllOrderUserList extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::connection('mysqlOrderAll')->create('consumer_order', function (Blueprint $table) {
            $table->unsignedBigInteger('orderId')->default(0)->primary()->comment("订单id");
            $table->unsignedInteger("brandId")->default(0)->comment("品牌 Id");
            $table->unsignedInteger("shopId")->default(0)->comment("店铺 ID");
            $table->unsignedInteger("userId")->default(0)->comment("用户 ID");
            $table->string("images", 1000)->default('')->comment("菜品图片 逗号分隔");
            $table->integer("originalPrice")->default(0)->comment("原价");
            $table->integer("payPrice")->default(0)->comment("订单实际收入 = payPrice + couponCostPrice");
//            $table->integer("realPayPrice")->default(0)->comment("实收");
            $table->integer("discountPrice")->default(0)->comment("总优惠价格");
//            $table->integer("realDiscountPrice")->default(0)->comment("订单实际优惠 = discountPrice - couponCostPrice");
            $table->tinyInteger("orderStatus")->default(0)->comment("订单状态");
            $table->integer("shouldPrice")->default(0)->comment("应收");
            $table->unsignedInteger('orderShouldPrice')->default(0)->comment('订单应付金额');
            $table->tinyInteger("payStatus")->default(0)->comment("支付状态 0 待支付 1 已支付");
            $table->integer("count")->default(0)->comment("菜品数量");
            $table->unsignedInteger('completeTime')->default(0)->comment('完成时间戳');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('更新人');

            $table->index(["userId"], "idx_userId");
//            $table->index(["orderId"], "idx_orderId");
            $table->index(["shopId"], "idx_shopId");
            $table->index(["createdAt"], "idx_createdAt");
            $table->index(["completeTime"], "idx_completeTime");
            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '用户订单列表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::connection('mysqlOrderAll')->drop('consumer_order');
    }
}
